package com.ys.erp.entity.data.bean;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 南山
 * @date 2025/09/19 18:09
 */
@Data
@TableName(value = "t_activity_turnable_redeem_record")
public class ActivityTurnableRedeemRecord {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableField(value = "user_id")
    private Long userId;

    @TableField(value = "activity_id")
    private Long activityId;

    @TableField(value = "type")
    private Integer type;

    @TableField(value = "prized_id")
    private Long prizedId;

    @TableField(value = "prized_info")
    private String prizedInfo;

    @TableField(value = "redeem_status")
    private String redeemStatus;

    @TableField(value = "redeem_time")
    private LocalDateTime redeemTime;


    @TableField(value = "send_status")
    private String sendStatus;

    @TableField(value = "goods_name")
    private String goodsName;

    @TableField(value = "goods_pic")
    private String goodsPic;

    @TableField(value = "remark")
    private String remark;

    @TableField(value = "waybill_no")
    private String waybillNo;

    @TableField(value = "delivery_name")
    /**
     * 收货人姓名
     */
    private String deliveryName;

    /**
     * 收货人手机号
     */
    @TableField(value = "delivery_phone")
    private String deliveryPhone;

    /**
     * 收货人省
     */
    @TableField(value = "delivery_province")
    private String deliveryProvince;

    /**
     * 收货人市
     */
    @TableField(value = "delivery_city")
    private String deliveryCity;

    /**
     * 收货人区
     */
    @TableField(value = "delivery_district")
    private String deliveryDistrict;

    /**
     * 详细收货地址
     */
    @TableField(value = "delivery_detail")
    private String deliveryDetail;

    @TableField(value = "version")
    @Version
    private String version;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;

    public String getDeliveryInfo() {
        return this.deliveryName + " " + this.deliveryPhone  + this.deliveryProvince + " " + this.deliveryCity + " " + this.deliveryDistrict + " " + this.deliveryDetail;
    }

    public ActivityTurntablePrized getActivityTurntablePrized() {
        if (StringUtils.isNotBlank(this.prizedInfo)) {
            return JSONObject.parseObject(this.prizedInfo, ActivityTurntablePrized.class);
        }
        return new ActivityTurntablePrized();
    }

    @AllArgsConstructor
    @Getter
    public enum Enums {

        NOT_REDEEMED,
        ISSUED,
        EXPIRED,

        PENDING_SHIPMENT,
        SHIPPED,
        COMPLETED,


    }

    public static final Map<String, String> ENUM_MAP = new HashMap<>();

    static {
        ENUM_MAP.put(Enums.NOT_REDEEMED.toString(), "未兑换");
        ENUM_MAP.put(Enums.ISSUED.toString(), "已发放");
        ENUM_MAP.put(Enums.EXPIRED.toString(), "已过期");

        ENUM_MAP.put(Enums.PENDING_SHIPMENT.toString(), "待发货");
        ENUM_MAP.put(Enums.SHIPPED.toString(), "已发货");
        ENUM_MAP.put(Enums.COMPLETED.toString(), "已完成");


    }

}
